! Configuration File for keepalived

global_defs {
    router_id {{ inventory_hostname | upper }}
}

vrrp_script check_ngx {
   script /server/scripts/check_ngx.sh
   interval 2   ###每两秒调一次
   weight 1     ###权重
   user root    ###root用户 不加默认root
}


vrrp_instance VI_{{ virtual_router_id }} {
    state {{ host_specific_vars[inventory_hostname].state }}
    nopreempt
    interface {{ vip_interface }}
    virtual_router_id {{ virtual_router_id }}
    priority {{ host_specific_vars[inventory_hostname].priority }}

    advert_int {{ advert_int }}
    authentication {
        auth_type PASS
        auth_pass {{ auth_pass }}
    }

    virtual_ipaddress {
        {{ vip_address }}/24 dev {{ vip_interface }}
    }
    
    track_script {
      check_ngx
    }

}

